//
//  ZBImageTool.h
//  ZBMediaLib
//
//  Created by xzb on 2018/6/24.
//

#import <Foundation/Foundation.h>

@interface ZBImageTool : NSObject

/**
 上传图片处理(先缩放->再质压)
 
 @param image 图像
 @param reqSize 用于计算压缩比例系数;
 @param compression 质量压缩比例数(UIImageJPEGRepresentation);
 */
+ (UIImage *)bdUploadImage:(UIImage *)image reqSize:(CGSize)reqSize compression:(CGFloat)compression;

/*
 计算压缩比例系数
 
 参考安卓实现 https://developer.android.com/reference/android/graphics/BitmapFactory.Options#inTargetDensity
 
 If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. The sample size is the number of pixels in either dimension that correspond to a single pixel in the decoded bitmap. For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels. Any value <= 1 is treated the same as 1. Note: the decoder uses a final value based on powers of 2, any other value will be rounded down to the nearest power of 2.
 */
+ (NSUInteger)inSampleSizeWithImage:(UIImage *)image reqSize:(CGSize)reqSize;

/*
 * 等比压缩image到指定大小
 *
 * 缩放比例:image最大边 / maxLength
 */
+ (UIImage *)imageRawSizeWithImage:(UIImage *)image maxLength:(CGFloat)maxLength;

/*
 * 压缩图片到指定的大小
 */
+ (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize image:(UIImage *)image;

+ (UIImage *)compressImageQuality:(UIImage *)image toByte:(NSInteger)maxLength;
@end
